<?php
namespace Admin\Controller;
use Think\Controller;
class IndexController extends Controller {
    protected $model = null;
    public function __construct() {
        parent::__construct();
        $this->model = D('Admin/Cats');
    }
    
    public function catadd(){
        if(!IS_POST){
            $this->assign('cats' , $this->model->getTree());
            $this->display();
        } else {
            //$cat = D('Admin/Cats');

            $this->model->add($_POST);
            $this->redirect('catlist');
            //echo $catadd ? redirect('./') : 'fail';        
        }
    }

    public function catlist(){
        $this->assign('cats' , $this->model->getTree());
        $this->display();
    }

    
    public function del(){
        $this->model->delete( I('get.cat_id') );
        $this->redirect('Admin/Index/catlist');
    }

    public function edit(){
        if(IS_POST){
            $cat_id = I('post.cat_id');
            $date = D('cats');
            $date->create();
            $date->where("cat_id=".$cat_id)->save();
            $this->redirect('catlist');
        }else{
            if(IS_GET){
                $this->assign('cats' , D('cats')->find("$_GET[cat_id]"));

            }  
            $this->display('catedit');  
        }
        
    }

    public function comlic(){
        $com = D('com')->where("status='0'")->select();
        $this->assign('com' , $com );
        $this->display('comlic');
    }

    public function reclic(){
        $rec = D('recruit')->where("status='0'")->select();
        $this->assign('rec' , $rec );
        $this->display('reclic');
    }
    
    public function userlist(){
        $this->display();
    }

    public function managelist(){
        $this->display();
    }

    public function comlist(){
        $this->display();
    }

    public function commlist(){
        $this->display();
    }
}